package com.lldpet.spring.cloud.demo.price.service.controller;

import com.lldpet.spring.cloud.demo.price.client.event.LocalApplicationEvent;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @desc：LocalEventController
 * @author: guanliang.xue
 * @date: 2021/5/10 13:21
 * @version:
 * @since:
 */
@RestController
@RequestMapping("local")
public class LocalEventController {

    @Resource
    private ApplicationEventPublisher applicationEventPublisher;

    @GetMapping("publish/event")
    public String onLocalEvent(String msg){
        applicationEventPublisher.publishEvent(new LocalApplicationEvent(msg,"spring 本地事件"));
        return "success";
    }
}
